<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String userName = user.getName();
	String nowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
%>
<div>
		<form id="weeklyForm" name="form" target="coreIframe"
			action="<%=request.getContextPath()%>/site/doWeeklyAdd" method="post" enctype="multipart/form-data">
			<div class="breadcrumb">
				<div class="bcIcon"></div>
				<ul class="bcNav">
					<li>增加周刊</li>
				</ul>
			</div>
			<input type="text" name="publicMan" value="<%=userName %>" hidden="true" />
			<input type="text" name="publicTime" value="<%=nowDate %>" hidden="true" />
			<table class="formTable">
				
				<tr>
					<td class="tdTitle">周刊名称：</td>
					<td><input type="text" name="weeklyName"></td>
				</tr>
				<tr>
					<td class="tdTitle">周刊图片：</td>
					<td><input type="file" id="weeklyImg" name="weeklyImg"></td>
				</tr>
				<tr>
					<td class="tdTitle">周刊内容：</td>
					<td>
						<div id="imgMap" class="maplink">
						    <img name="test" id= "mapLoad" usemap="#Map" class='imageMaps' />
						</div>
					</td>
				</tr>
				<tr>
					<td class="tdTitle"></td>
					<td>
						<div>
							<input class="input-btn-microsoft" type="submit" value="提交" id="click_btn">
							<a class="a-btn-microsoft"
								href="#">取消</a>
						</div>
					</td>
				</tr>
			</table>
			</form>
</div>
<iframe name="coreIframe" style="display: none"></iframe>
<script type="text/javascript">
$(function(){
	
	$('#weeklyImg').change(function() {
		var file = this.files[0];
		var reader = new FileReader();
		reader.readAsDataURL(file);
		reader.onload = function() {
			$('#mapLoad').attr('src', reader.result);
			$('#imgMap').imageMaps({
				callback:function(){
					bindEditor();
				}
			});
			//初始化编辑器
			bindEditor();
		};
	});
	

});

//绑定编辑器
function bindEditor(){
	var editor = KindEditor.create('.editor', {
		width: '100%',
		height: '200px',
		filterMode: false, //默认不过滤HTML
		resizeType: 1,
		fileManagerJson:global.contextPath+'/upload4KindEditor',
		uploadJson:global.contextPath+'/upload4KindEditor', 
		allowFileManager: true
	});
}
</script>
</html>